package edu.njust.Service.user.serviceimpl;

import edu.njust.Service.user.UserService;
import edu.njust.dao.UserMapper;
import edu.njust.domain.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public User getUserByID(int id, String pwd) {
        User user = userMapper.getUserByID(id, pwd);
        return user;
    }

    @Override
    public List<User> getUsers() {
        List<User> users = userMapper.getUsers();
        return users;
    }

    @Override
    public boolean addUser(User user) {
        int res = userMapper.addUser(user);
        return res>0;
    }

    @Override
    public boolean updateUserPwd(User user) {
        return false;
    }

    @Override
    public boolean updateUserOther(User user) {
        return false;
    }

    public boolean deleteUser(int CM_ID, String CM_PWD, String modifiedUser, Date modifiedTime) {
        int res = userMapper.deleteUser(CM_ID,CM_PWD,modifiedUser,modifiedTime);
        return res>0;
    }

}
